package org.itfarmer.service.impl;

import java.util.List;

import org.itfarmer.dao.StaffinfoDAO;
import org.itfarmer.dao.pojo.Staffinfo;
import org.itfarmer.service.StaffinfoService;

public class StaffinfoServiceImpl implements StaffinfoService {

	private StaffinfoDAO staffinfoDAO;
	
	/*
	 * 	(non-Javadoc)
	 * @see org.itfarmer.service.BaseService#countService()
	 */
	public Integer countService() {
		Integer rows = staffinfoDAO.count(Staffinfo.class);
		return rows;
	}

	/*
	 * (non-Javadoc)
	 * @see org.itfarmer.service.StaffinfoService#searchAll(java.lang.Integer, java.lang.Integer)
	 */
	public List<Staffinfo> searchAll(Integer pageNow, Integer pageSize) {
		Integer firstRow = (pageNow - 1) * pageSize;
		Integer maxRow = pageSize;
		List<Staffinfo> staffList = staffinfoDAO.read(Staffinfo.class, firstRow, maxRow);
		return staffList == null || staffList.size() == 0 ? null : staffList;
	}

	/*
	 * (non-Javadoc)
	 * @see org.itfarmer.service.StaffinfoService#addStaffinfo(org.itfarmer.dao.pojo.Staffinfo)
	 */
	public boolean addStaffinfo(Staffinfo staffinfo) {
		Integer pk = staffinfoDAO.create(staffinfo);
		return pk > 0 ? true : false;
	}
	
	/*
	 * (non-Javadoc)
	 * @see org.itfarmer.service.StaffinfoService#checkedWorkid(java.lang.Integer)
	 */
	public boolean checkedWorkid(Integer workid) {
		Staffinfo staff = staffinfoDAO.readByWorkid(workid);
		if (staff != null) {
			return true;
		} else {
			return false;
		}
	}
	
	/*
	 * (non-Javadoc)
	 * @see org.itfarmer.service.StaffinfoService#searchById(java.lang.Integer)
	 */
	public Staffinfo searchByWorkid(Integer workid) {
		if (workid == null) {
			return null;
		}
		Staffinfo staff = staffinfoDAO.readByWorkid(workid);
		return staff;
	}

	public StaffinfoDAO getStaffinfoDAO() {
		return staffinfoDAO;
	}

	public void setStaffinfoDAO(StaffinfoDAO staffinfoDAO) {
		this.staffinfoDAO = staffinfoDAO;
	}

	
}
 